#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
const int N = 100005;
int n, k, q[N], pre[N][205];
long long ft[N], gt[N], sum[N];
long long *f, *g;
inline long long y(int i) { return (sum[i] * sum[i] - g[i]); }
inline int x(int i) { return sum[i]; }
inline int kk(int i) { return sum[i]; }
inline int read() {
  int ch = getchar(), res = 0;
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch <= '9' && ch >= '0') {
    res = (res << 3) + (res << 1) + ch - '0';
    ch = getchar();
  }
  return res;
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif
#endif
  n = read(), k = read();
  for (register int i = 1; i <= n; ++i) {
    sum[i] = read();
    sum[i] += sum[i - 1];
  }
  f = ft, g = gt;
  for (register int j = 1; j <= k; ++j) {
    register int l = 1, r = 1;
    q[1] = 0;
    for (register int i = 1; i <= n; ++i) {
      while (l < r && 1ll * kk(i) * (x(q[l + 1]) - x(q[l])) >= (y(q[l + 1]) - y(q[l])))
        ++l;
      f[i] = g[q[l]] + (sum[i] - sum[q[l]]) * sum[q[l]];
      pre[i][j] = q[l];
      while (l < r && (y(i) - y(q[r])) * (x(q[r]) - x(q[r - 1])) <=
                          (y(q[r]) - y(q[r - 1])) * (x(i) - x(q[r])))
        --r;
      q[++r] = i;
    }
    std::swap(f, g);
  }
  printf("%lld\n", g[n]);
  register int tmp = pre[n][k];
  printf("%d ", tmp);
  for (register int i = k - 1; i > 0; --i) {
    printf("%d ", tmp = pre[tmp][i]);
  }
  return 0;
}